package com.scaffold.commons.spring;

import java.util.Properties;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

import com.scaffold.commons.config.AbstractConfig;

/**
 * @author wangjg
 *
 */
public class BeanPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
	
	private AbstractConfig config ;

	public BeanPlaceholderConfigurer() {
		//default value
		this.setSystemPropertiesMode(SYSTEM_PROPERTIES_MODE_OVERRIDE);
		this.setIgnoreResourceNotFound(true);
		this.setIgnoreUnresolvablePlaceholders(true);
	}
	
	protected String resolvePlaceholder(String placeholder, Properties props) {
		return this.config.getString(placeholder);
	}

	public void setConfig(AbstractConfig config) {
		this.config = config;
	}
	
}
